<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../../vue.js"></script>
  <style>
    .public {
      width: 100px;
      height: 100px;
      background-color: green;
    }
  </style>
</head>

<body>
  <div id="app">
    <!-- 动态style属性
    v-bind:style='',值是属性名和属性值组成的对象或者样式对象组成的数组
    1.v-bind绑定style属性,值是由样式组成的对象
    2.v-bind绑定style属性,值是样式对象组成的数组
    3.style可以和v-bind共同使用,也可以把属性值作为数据保存在data中
    4.v-bind保存属性值,style=''引号里面的值必须是数组或对象,所以在属性属性时要在外面加对象

    -->
    <div style="width: 100px;height: 100px" :style="box1css">box1</div>
    <div style="width: 100px;height: 100px" :style="{
      fontSize: '30px',
      color: 'green',
      fontWeight: 'bold'
    }">box2</div>
    <div style="width: 100px;height: 100px" :style="{background:style}">box3</div>

  </div>
  <script>
    Vue.config.productionTip = false

    const vm = new Vue({
      el: "#app",
      data() {
        return {
          msg: "hello vue",
          box1css: {
            fontSize: '30px',
            color: 'red',
            fontWeight: 'bold'
          },
          box2css: [
            { fontSize: '30px' },
            { color: 'red' },
            { fontWeight: 'bold' },
          ],
          style: 'red'
        }
      }
    })
  </script>
</body>

</html>